<template>
  <tn-list bottom-line :line-offset="false" icon="right" :custom-style="customListStyle" @click="handleClick">
    <view class="components-options-list tn-flex-center-start">
      <view class="icon">
        <tn-icon :icon="icon" :color="iconColor"></tn-icon>
      </view>
      <view class="title">
        <slot></slot>
      </view>
    </view>
  </tn-list>
</template>

<script lang="ts" setup>
import { CSSProperties } from 'vue'
import TnList from '@/tuniao-ui/components/tn-list/src/List.vue'
import TnIcon from '@/tuniao-ui/components/tn-icon/src/Icon.vue'

type Props = {
  /** icon */
  icon: string,
  /** icon颜色 */
  iconColor?: string
}
const props = withDefaults(defineProps<Props>(), {
  iconColor: '#01BEFF'
})

// emits
type Emits = {
  (e: 'click'): void
}
const emits = defineEmits<Emits>()

const customListStyle: CSSProperties = {
  padding: '20rpx 0'
}

const handleClick = () => {
  emits('click')
}
</script>

<script lang="ts">
export default {
  options: {
    // 在微信小程序中将组件节点渲染为虚拟节点，更加接近Vue组件的表现(不会出现shadow节点下再去创建元素)
    virtualHost: true
  }
}
</script>

<style lang="scss" scoped>
.components-options-list {
  width: 100%;
  line-height: 1;

  .icon {
    font-size: 50rpx;
    margin-right: 16rpx;
    // border-radius: 50%;
    overflow: hidden;
  }
}
</style>
